package com.ant.storage.mapper;

import com.ant.storage.dto.InventoryDto;
import com.ant.storage.excel.InventoryCensusExecl;
import com.ant.storage.pojo.Inventory;
import com.ant.storage.pojo.InventoryLog;
import com.ant.storage.vo.BalanceInventoryVo;
import com.ant.storage.vo.CommodityVo;
import com.ant.storage.vo.InventoryCensusVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author melon
 * @since 2022-03-16
 */
public interface InventoryMapper extends BaseMapper<Inventory> {
    /**
     * 出库对商品进行库存减少
     * @param warehouse_id 仓库id
     * @param commodity_id 商品id
     * @param commodity_out_quantity 减少库存数量
     */
    void stockSubtract(Integer warehouse_id, Integer commodity_id, Integer commodity_out_quantity);

    /**
     * 入库对商品进行库存增加
     * @param warehouse_id 仓库id
     * @param commodity_id 商品id
     * @param commodity_enter_quantity 增加库存数量
     */
    void stockAdd(Integer warehouse_id, Integer commodity_id, Integer commodity_enter_quantity);

    List<CommodityVo> findWarehouseAndInventory(@Param("wid") Integer wid);

    List<InventoryCensusVo> findCensus(InventoryDto dto);

    List<InventoryCensusVo> findCensusList(InventoryDto dto);

    List<InventoryCensusExecl> exportCensus(@Param("warehouseId")Integer warehouseId,
                                            @Param("commodityType")String commodityType,
                                            @Param("previousTime")List<String> previousTime,
                                            @Param("time")List<String> time);

    InventoryCensusExecl exportCensusTotal(@Param("warehouseId")Integer warehouseId,
                                           @Param("previousTime")List<String> previousTime,
                                           @Param("time")List<String> time);


    String balanceQuantity(@Param("stock")Integer stock,
                           @Param("id")Integer id,
                           @Param("time")List<String> time);
    BigDecimal balancePrice(@Param("stock")Integer stock,
                            @Param("id")Integer id,
                            @Param("time")List<String> time);

    List<InventoryCensusExecl> InventoryCensusExeclList(@Param("stock")Integer warehouseId);


    String balanceQuantityss(@Param("stock")Integer stock,
                             @Param("commodityType")String commodityType,
                             @Param("commodityId")Integer commodityId,
                             @Param("time")List<String> time);

    BigDecimal balancePricess(@Param("stock")Integer stock,
                            @Param("commodityType")String commodityType,
                            @Param("commodityId")Integer commodityId,
                            @Param("time")List<String> time);

    List<InventoryLog> findAllbalanceQuantity( @Param("warehouseId")Integer warehouseId, @Param("previousTime") List<String> previousTime);

    List<BalanceInventoryVo> BalanceInventoryList(@Param("wid")Integer wid);


    List<InventoryCensusVo> findBalanceList(InventoryDto dto);


    List<InventoryCensusExecl> exportCensusList(@Param("wid")Integer wid, @Param("commodityType")String commodityType,
                                                @Param("time") List<String> time,
                                                @Param("balanceNumber") String balanceNumber);
    String balanceNumber(@Param("id")Integer id);

    String selectCommodityName(@Param("inventoryId") Integer inventoryId);

    List<CommodityVo> findWarehouseCarInventory(@Param("id")Integer id);
}
